import java.util.Arrays;

public class t5 {
    public static void main(String[] args){
        //String s = "xaabacxcabaax";
        String s = "abbcccbbbcaaccbababcbcabca";
        MaxStr p =new MaxStr();
        p.longestPalindome(s);


    }
}
class MaxStr {
    //s = "babbabd"
    public static void longestPalindome(String s) {
        String[] arr = new String[s.length()];
        arr = s.split("");
        int[] num = new int[arr.length];

        int c = 0;
        int a = 0;

        for (int i = 0; i <= arr.length-1; i++) {
            bb:   for (int j = arr.length-1 ; j > i; j--) {
            System.out.println(j);
              c= 1;a=0;

                //System.out.println(j);
                if (arr[i].equals(arr[j])) {
                    if (j - i == 2) {
                        num[i] = 3;
                        break;
                    }
                    ;
                    if (j - i == 1) {
                        num[i] = 2;
                        break ;
                    }
                    ;
                    if ((j - i - 1) % 2 == 1 ) {
                        for (int k = i + 1; c <= (j - i -1) / 2; k++,c++) {

                            if (arr[k].equals(arr[j - c])) {
                                a++;
                                if ( a == (j - i - 1) / 2) {
                                    num[i] = j - i + 1;
                                    break bb;
                                }
                            }
                            ;
                            ;
                        }
                    } else if ((j - i - 1) % 2 == 0) {
                        for (int k = i + 1; c <= (j - i - 1) / 2; k++,c++) {

                            if (arr[k].equals(arr[j - c]) ) {
                                    a++;
                                if ((j - i - 1) / 2 == a ) {
                                    num[i] = j - i + 1;

                                    break bb;
                                }
                                ;
                            }
                            ;
                        }
                        ;

                    }

                }
            }


        }
        if(arr.length==1){
            num[0]=1;
        }
        for(int i = 0; i<=arr.length-1;i++){
            if(num[i]==0){
                num[i]=1;
            }
        }





        System.out.println(Arrays.toString(num));
        int max = num[0];
        int k = 0;
        for (int i = 1; i <= arr.length - 1; i++) {
            if (max < num[i]) {
                max = num[i];
            };
        }
        for(int i = 0; i<=num.length-1;i++){
            if(max == num[i]){
                k = i;
                break;
            }
        }
        System.out.println(k);
        String str ="";
        for(int i = k; i<=max+k-1 ; i++){
            str +=arr[i];
        }
        System.out.println(str);

    }
}








